package cn.com.miao.lynx.test.api.rpc;

import cn.com.miao.lynx.common.base.controller.CommonController;
import cn.com.miao.lynx.common.core.model.Result;
import cn.com.miao.lynx.service.system.service.GrpcSysUserService;
import cn.com.miao.lynx.service.system.service.RemoteSysUserService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * SysUserApi
 *
 * @title: SysUserApi
 * @description:
 * @author: dengmiao
 * @create: 2019-12-24 15:14
 **/
@Slf4j
@AllArgsConstructor
@RequestMapping("rpc/user")
@RestController
public class SysUserApi implements CommonController {

    private final RemoteSysUserService sysUserService;

    private final GrpcSysUserService grpcSysUserService;

    @GetMapping("dubbo")
    public ResponseEntity<Result> dubbo() {
        return sysUserService.findAll();
    }

    @GetMapping("grpc")
    public ResponseEntity<Result> grpc(String username) {
        return ok(grpcSysUserService.findUserByUsername(username));
    }
}
